package com.beecloud.learning.charpter.three;

import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * User: hengsun
 * Date: 3/28/17
 * Time: 1:28 PM
 * Description:
 */
public class ThisEscape {
    private  int num;
    public ThisEscape(EventSource eventSource) {
        eventSource.registerListener(new EventListener() {
            @Override
            public void onEvent(Event event) {
                doSomething(event);
            }
        });
        num = 42;
    }

    private void doSomething(Event e) {
        if (num != 42) {
            System.out.println("Race condition detected at " +
                    new Date());
        }
    }


}
